package com.itheima.aliyunpicuploadspringbootstart.config;

import com.aliyun.oss.OSSClient;
import com.itheima.aliyunpicuploadspringbootstart.pojo.AliyunOssProperties;
import com.itheima.aliyunpicuploadspringbootstart.service.PicUploadService;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动生成AliyunOssProperties的bean
 * @author 郭文亮
 * @since 2021/11/22 23:25
 */

@Configuration
@EnableConfigurationProperties(AliyunOssProperties.class)
public class AutoConfigure {
    @Bean
    public OSSClient ossClient(AliyunOssProperties aliyunOssProperties) {
        return new OSSClient(aliyunOssProperties.getEndpoint(), aliyunOssProperties.getAccessKeyId(), aliyunOssProperties.getAccessKeySecret());
    }

    @Bean
    public PicUploadService picUploadService() {
        return new PicUploadService();
    }
}

